<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/contentLayout.xhtml">

	<ui:define name="stylesheets">
		<style type="text/css">
		.table tr.odd td.rich-spinner-input-container, 
		.table tr.even td.rich-spinner-input-container, 
		.table tr.odd .rich-spinner-buttons td,
		.table tr.even .rich-spinner-buttons td {
			height: auto;
			padding: 0;
		}
		</style>
	</ui:define>
	
	<ui:define name="road">
		<span><h:outputLink value="/luyuan/sale/orderListForSale.jsf">我的订单</h:outputLink> &gt;&gt; 新建订单 </span>
	</ui:define>

	<!-- content -->
	<ui:define name="content">
		<rg:areaPanel>
			<rg:wizardPanel id="orderWizard">
				<ui:insert name="orderFormula" />
			
				<rg:titlePanel headerTitle="#{messages.luyuan_crm_sale_choose_product}">
					<ui:define name="headerActions">
						<a:commandButton value="增加" styleClass="button" actionListener="#{param_action.addProduct}"
							immediate="true" oncomplete="UI.instance.showDialog({id:'addProduct', src:'/luyuan/sale/addProduct.jsf'});" />
						<a:commandButton value="批量删除" styleClass="button" actionListener="#{param_action.deleteProducts}" 
							immediate="true" reRender="productTable"/>
					</ui:define>

					<rg:table id="productTable" value="#{param_action.productTableModel}" var="item">
						<rg:column property="product.id" type="checkbox" headerType="checkbox" headerStyle="width:4%;" />
						<rg:column property="name" title="产品名称" width="100" />
						<rg:column property="specification" title="产品规格" width="100" />
						<rg:column property="price" title="产品价格" width="100" />
						<rg:column property="product.productType.typeName" title="产品类型" width="100" />
						<rg:column title="数量" width="100" >
							<rich:inputNumberSpinner value="#{item.count}"/>
						</rg:column>
						<rg:column title="是否赠品" width="100" >
	                    	<h:selectOneMenu value="#{item.gift}" converter="#{booleanConverter}" 
	                    		styleClass="select">
	                    		<f:selectItems value="#{booleanProvider.getSelectItems(null)}" />
	                    	</h:selectOneMenu>
						</rg:column>
						<rg:column type="oper" title="积分兑换">
							<ul class="links">
								<li>
			                    	<h:selectOneMenu value="#{item.exchangeIntegral}" styleClass="select">
			                    		<f:selectItem itemValue="0" itemLabel="0"/>
			                    		<f:selectItem itemValue="#{item.price.intValue() * 10}" itemLabel="#{item.price.intValue() * 10}"/>
			                    		<a:support event="onchange" actionListener="#{param_action.computeAmount}" ajaxSingle="true" />
			                    	</h:selectOneMenu> 
								</li>
							</ul>
						</rg:column>
						<rg:column type="oper" title="#{messages.luyuan_crm_operator}">
							<ul class="links">
								<li>
									<a:commandLink value="#{messages.luyuan_crm_delete}" reRender="productTable"
									immediate="true" action="#{param_action.deleteProductById(item.product.id)}" />
								</li>
							</ul>
						</rg:column>
					</rg:table>
				</rg:titlePanel>
					<rg:fieldSet column="singleLine">
						<rg:outputText id="currentIntegral" rendered="#{param_action.isMember()}" 
							value="#{param_action.oldIntegral}" label="可用积分" />
					</rg:fieldSet>
			</rg:wizardPanel>
		</rg:areaPanel>
		<a:form>
            <a:jsFunction name="reRenderProductTable" reRender="productTable"/>
        </a:form>
	</ui:define>
</ui:composition>